home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 26 / Cream of the Crop 26.iso / doom / quake.zip / HIPGRAPL.ZIP / HIP_EXPL.QC < prev    next >
Text File  |  1997-01-23  |  5KB  |  205 lines

  1. /* Exploder QuickC program
  2.    By Jim Dose'  9/13/96
  3.    Copyright (c)1996 Hipnotic Interactive, Inc.
  4.    All rights reserved.
  5.    Do not distribute.
  6. */
  7.  
  8. float USE_PARTICLES = 1;
  9.  
  10. void() BecomeExplosion;
  11.  
  12. void() exploder_fire =
  13.     {
  14.     local entity temp;
  15.  
  16.     temp = self;
  17.     activator = other;
  18.     SUB_UseTargets ();
  19.     self = temp;
  20.     other = self;
  21.    if (self.dmg<120)
  22.       {
  23.       sound (self , CHAN_AUTO, "misc/shortexp.wav", self.volume, self.speed);
  24.       }
  25.    else
  26.       {
  27.       sound (self , CHAN_AUTO, "misc/longexpl.wav", self.volume, self.speed);
  28.       }
  29.    T_RadiusDamage (self, self.owner, self.dmg, other);
  30.    if (self.spawnflags & USE_PARTICLES)
  31.       {
  32.       WriteByte (MSG_BROADCAST, SVC_TEMPENTITY);
  33.       WriteByte (MSG_BROADCAST, TE_EXPLOSION);
  34.       WriteCoord (MSG_BROADCAST, self.origin_x);
  35.       WriteCoord (MSG_BROADCAST, self.origin_y);
  36.       WriteCoord (MSG_BROADCAST, self.origin_z);
  37.       }
  38.    BecomeExplosion();
  39.     };
  40.  
  41. void() exploder_use =
  42.     {
  43.     if (self.delay)
  44.         {
  45.         self.nextthink = time + self.delay;
  46.         self.delay = 0;
  47.         self.think = exploder_fire;
  48.         }
  49.     else
  50.         {
  51.         exploder_fire();
  52.         }
  53.     };
  54.  
  55. /*QUAKED func_exploder (0.4 0 0) (0 0 0) (8 8 8) particles
  56.   Spawns an explosion when triggered.  Triggers any targets.
  57.  
  58.   "dmg" specifies how much damage to cause.  Negative values
  59.   indicate no damage.  Default or 0 indicates 120.
  60.   "volume" volume at which to play explosions (default 1.0)
  61.   "speed" attenuation for explosions (default normal)
  62. */
  63. void() func_exploder =
  64.     {
  65.    precache_sound ("misc/shortexp.wav");
  66.    precache_sound ("misc/longexpl.wav");
  67.     self.classname = "exploder";
  68.     self.use = exploder_use;
  69.     if ( self.dmg == 0 )
  70.        {
  71.        self.dmg = 120;
  72.        }
  73.     if ( self.dmg < 0 )
  74.        {
  75.        self.dmg = 0;
  76.        }
  77.    if ( self.speed == 0 )
  78.        {
  79.       self.speed = 1;
  80.        }
  81.    if ( self.volume == 0 )
  82.        {
  83.       self.volume = 1.0;
  84.        }
  85.    };
  86.  
  87. void() multi_exploder_fire =
  88.     {
  89.     local entity temp;
  90.    local entity expl;
  91.  
  92.    self.nextthink = time + self.wait;
  93.    if (self.state == 0)
  94.       {
  95.       self.state = 1;
  96.       self.duration = time + self.duration;
  97.       temp = self;
  98.       activator = other;
  99.       SUB_UseTargets ();
  100.       self = temp;
  101.       other = self;
  102.       }
  103.    if (time > self.duration)
  104.       {
  105.       remove(self);
  106.       return;
  107.       }
  108.    expl = spawn();
  109.    expl.owner = self.owner;
  110.    expl.dmg = self.dmg;
  111.    expl.origin_x = self.absmin_x + (random() * (self.absmax_x - self.absmin_x));
  112.    expl.origin_y = self.absmin_y + (random() * (self.absmax_y - self.absmin_y));
  113.    expl.origin_z = self.absmin_z + (random() * (self.absmax_z - self.absmin_z));
  114.    sound (expl , CHAN_VOICE, "misc/shortexp.wav", self.volume, self.speed);
  115.    T_RadiusDamage (expl, self.owner, self.dmg, other);
  116.    if (self.spawnflags & USE_PARTICLES)
  117.       {
  118.       WriteByte (MSG_BROADCAST, SVC_TEMPENTITY);
  119.       WriteByte (MSG_BROADCAST, TE_EXPLOSION);
  120.       WriteCoord (MSG_BROADCAST, expl.origin_x);
  121.       WriteCoord (MSG_BROADCAST, expl.origin_y);
  122.       WriteCoord (MSG_BROADCAST, expl.origin_z);
  123.       }
  124.    temp = self;
  125.    self = expl;
  126.    BecomeExplosion();
  127.    self = temp;
  128.     };
  129.  
  130. void( vector loc, float rad, float damage, float dur, float pause, float vol) multi_explosion =
  131.     {
  132.    local entity temp;
  133.  
  134.    temp = self;
  135.    self = spawn();
  136.    self.origin = loc;
  137.    self.dmg = damage;
  138.    self.duration = dur;
  139.    self.wait = pause;
  140.    self.owner = world;
  141.    self.absmin = self.origin - (rad * '1 1 1');
  142.    self.absmax = self.origin + (rad * '1 1 1');
  143.    self.think = multi_exploder_fire;
  144.    self.volume = vol;
  145.    multi_exploder_fire();
  146.    self = temp;
  147.     };
  148.  
  149. void() multi_exploder_use =
  150.     {
  151.    if (self.delay)
  152.         {
  153.         self.nextthink = time + self.delay;
  154.         self.delay = 0;
  155.       self.think = multi_exploder_fire;
  156.       }
  157.     else
  158.         {
  159.       self.think = multi_exploder_fire;
  160.       multi_exploder_fire();
  161.         }
  162.     };
  163.  
  164. /*QUAKED func_multi_exploder (0.4 0 0) ?
  165.   Spawns an explosion when triggered.  Triggers any targets.
  166.   size of brush determines where explosions will occur.
  167.  
  168.   "dmg" specifies how much damage to cause from each explosion
  169.   Negative values indicate no damage.  Default or 0 indicates 120.
  170.   "delay" delay before exploding (Default 0 seconds)
  171.   "duration" how long to explode for (Default 1 second)
  172.   "wait" time between each explosion (default 0.25 seconds)
  173.   "volume" volume to play explosion sound at (default 0.5)
  174.   "speed" attenuation for explosions (default normal)
  175.  
  176. */
  177. void() func_multi_exploder =
  178.     {
  179.    precache_sound ("misc/shortexp.wav");
  180.    precache_sound ("misc/longexpl.wav");
  181.     self.classname = "exploder";
  182.    self.use = multi_exploder_use;
  183.    setmodel(self,self.model);
  184.    self.movetype = MOVETYPE_NONE;
  185.     self.modelindex = 0;
  186.    self.model = "";
  187.     if ( self.dmg == 0 )
  188.        {
  189.        self.dmg = 120;
  190.        }
  191.     if ( self.dmg < 0 )
  192.        {
  193.        self.dmg = 0;
  194.        }
  195.    if (self.duration == 0)
  196.       self.duration = 1.0;
  197.    if (self.speed == 0)
  198.       self.speed = 1.0;
  199.    if (self.volume == 0)
  200.       self.volume = 0.5;
  201.    if (self.wait == 0)
  202.       self.wait = 0.25;
  203.    self.state = 0;
  204.    };
  205.